import { INCREMENT, DECREMENT } from './action-types'
import store from './store'
export const increment = data => ({ type: INCREMENT, data })
export const decrement = data => ({ type: DECREMENT, data })
// action 分为同步action和异步action 同步action直接返回对象 异步action返回一个函数
// 异步action需要借助react-thunk 中间件
export const incrementasync = (data, time) => {
  return () => {
    // 模拟异步操作
    setTimeout(() => {
      store.dispatch(increment(data))
    },time)
  }
}